// pages/product/product.js
var network = require("../../utils/network.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    category: [],
  },
  /**
   * 商品分类列表
  */
  title: function () {
    let that = this;
    let URL = network.server() + 'goods/get-list-with-category';
    let Params = {};
    let Method = 'GET';
    let Message = '';
    network.requestLoading(URL, Params, Method, Message, function (res) {
      console.log('商品分类列表---', res)
      if (res.code == 0) {
        let category = res.data;
        that.setData({
          category: category,
        })
      }
    }, function () {
      // wx.showToast({
      //   title: '加载数据失败',
      // })
    })
  },


  /*商品详情*/
  productDetail: function(e){
    var that = this; 
    var goods_title = e.currentTarget.dataset.goods_title;
    var model_id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '../productDetail/productDetail?goods_title=' + goods_title + '&model_id=' + model_id,
    })
  },
  /***
   * 页面加载
  */
  onLoad: function (options){
    this.title();
  },
  onShow: function (){
    
  },
  onShareAppMessage: function () { }
})